package com.irdstudio.efp.flow.executor.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.irdstudio.efp.flow.common.constance.FlowConstance;
import com.irdstudio.efp.flow.common.vo.EngineVO;
import com.irdstudio.efp.flow.service.vo.InstFlowTaskVO;

/**
 * 
 * 查看的页面插件类型
 * 
 * @author Cytus_
 * @since 2018年5月29日 下午7:45:26
 * @version 1.0
 *
 */
@Service("viewPagePluginTaskExecutor")
public class ViewPagePluginTaskExecutor extends PagePluginTaskExecutor {
	
	private static Logger logger = LoggerFactory.getLogger(PagePluginTaskExecutor.class);

	public EngineVO doTask(EngineVO evo, InstFlowTaskVO task)  throws Exception {
		logger.info("节点实例号:"+ evo.getNodeInstanceId() +", 任务编号："+ evo.getTaskId() +"执行当前任务页面插件开始......");
		
		//如果当前任务是暂停，再次进入该方法则表示该页面插件任务已经处理完成，即将任务状态修改为完成，否则为第一次进入，将任务状态修改为暂停
		
		if (FlowConstance.TASK_STATUS_END.equals(task.getTaskState())) {
			evo.setTaskExecuteStatus(FlowConstance.TASK_STATUS_END);
			logger.info("节点实例号:"+ evo.getNodeInstanceId() +", 任务编号："+ evo.getTaskId() +"当前任务页面插件已执行!");
			return evo;
		}
		evo.setTaskExecuteStatus(FlowConstance.TASK_STATUS_END);
		if (evo.getPluginVo().getVos().containsKey(FlowConstance.DEFAULT_PLUGIN_VO_KEY)) {
		    evo = this.setDefaultParam2EVO(evo, task);
		}
		logger.info("节点实例号:"+ evo.getNodeInstanceId() +", 任务编号："+ evo.getTaskId() +"执行当前任务页面插件结束......");
		return evo;
	}
	
}
